package com.example.mypc.scrollviewpager;

import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    private ViewPager vp;
    private TextView tv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        List<ImageView> imageViews=new ArrayList<>();
        for(int i=0;i<5;i++){
            ImageView imageView=new ImageView(this);
            imageView.setImageResource(R.mipmap.ic_launcher);
            LinearLayout.LayoutParams params=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
            imageView.setLayoutParams(params);
            imageViews.add(imageView);
        }
       MyAdapter adapter=new MyAdapter();
        adapter.setContent(imageViews);
        vp.setAdapter(adapter);
        tv.setText("lalallllllllll");
    }

    private void initView() {
        vp = (ViewPager) findViewById(R.id.vp);
        tv = (TextView) findViewById(R.id.tv);
    }
}
